<template>
  <div id="app">
    <el-form :model="ruleForm" :rules="rules" ref="ruleForm" label-width="180px" class="demo-ruleForm">
      <!-- 积分抵扣比例 -->
      <el-form-item label="积分抵扣比例：" prop="deductionRatio" required>
        <el-input v-model.number="ruleForm.deductionRatio" placeholder="(积分抵扣多少金额)" ></el-input>
        
      </el-form-item>
      <!-- 满多少可以抵扣 -->
      <el-form-item label="满多少可以抵扣：" prop="minAmountToDeduct" required>
        <el-input v-model.number="ruleForm.minAmountToDeduct" placeholder="消费必须满足一定额度才可使用,0代表无限制"></el-input>
        
      </el-form-item>
      <!-- 单次最大抵扣积分 -->
      <el-form-item label="单次最大抵扣积分：" prop="maxPointsPerTime" required>
        <el-input v-model.number="ruleForm.maxPointsPerTime" placeholder="限制一次只能使用多少积分,0代表无限制"></el-input>
        
      </el-form-item>
      <!-- 提交按钮 -->
      <el-form-item>
        <el-button type="primary" @click="submitForm('ruleForm')">提交</el-button>
      </el-form-item>
    </el-form>
  </div>
</template>

<script>
export default {
  data() {
    return {
      ruleForm: {
        deductionRatio: '',
        minAmountToDeduct: '',
        maxPointsPerTime: ''
      },
      rules: {
        deductionRatio: [
          { required: true, message: '请输入积分抵扣比例', trigger: 'blur' },
          { type: 'number', message: '积分抵扣比例必须为数字值' }
        ],
        minAmountToDeduct: [
          { required: true, message: '请输入满多少可以抵扣', trigger: 'blur' },
          { type: 'number', message: '满多少可以抵扣必须为数字值' }
        ],
        maxPointsPerTime: [
          { required: true, message: '请输入单次最大抵扣积分', trigger: 'blur' },
          { type: 'number', message: '单次最大抵扣积分必须为数字值' }
        ]
      }
    };
  },
  methods: {
    submitForm(formName) {
      this.$refs[formName].validate((valid) => {
        if (valid) {
          alert('提交成功!');
          // 这里可以执行提交操作，例如发送请求到服务器
        } else {
          //  console.log('error submit!!');
          return false;
        }
      });
    }
  }
};
</script>

<style scoped>

.el-form {
  margin-top: 20px;
  width: 500px; /* 根据需要调整宽度 */
}
</style>
